<template>
  <div class>
    <head-nav></head-nav>
    <!-- 占位 -->
    <div class="zanwei-top"></div>
    <!-- <div class="rapdetail" v-if="itemObj">
          <div class="ph_faddish">
            <img :src="itemObj.TP[0]" />
          </div>
          <div class="name_faddish">
            <h3 class="tit">{{itemObj.SPMC}}</h3>
            <ul>
              <router-link class="rap_rout" :to="{path:'/rappay'}" tag="div">
                <li class="btn_faddish" @click="exchangeFn(itemObj.XJ, itemObj.ID)">立即抢购</li>
              </router-link>
              <li class="price">
                <div>原价 {{itemObj.JE }}</div>
                <p>现价 {{itemObj.XJ}}</p>
              </li>
            </ul>
          </div>
          <div class="detail_faddish contentA">
            <div v-html="itemObj.MS"></div>
          </div>
    </div>-->
    <!-- new weigang start -->
    <div class="hbbox">
      <div class="topimg">
        <!-- <img :src="itemObj.TP[0]" > -->
        <mt-swipe :auto="4000">
          <mt-swipe-item v-for="(item,index) in itemObj.XQT" :key="index">
            <img :src="item" />
          </mt-swipe-item>
        </mt-swipe>
      </div>
      <div class="title">{{itemObj.SPMC}}</div>
      <div class="detailsm">
        <div class="jg" v-if="itemObj.XJ!=0 && itemObj.JF==0" :style="textColor">
          ￥{{itemObj.XJ}}
          <span
            v-if="(itemObj.XJ!=itemObj.JE && itemObj.JE!=0 && itemObj.JE!=null)"
          >原价 {{itemObj.JE }}</span>
        </div>
        <div
          class="jg"
          v-else-if="itemObj.XJ==0 && itemObj.JF!=0"
          :style="textColor"
        >{{itemObj.JF}}积分</div>
        <div class="jg" :style="textColor" v-else-if="itemObj.XJ!=0 && itemObj.JF!=0">
          ￥{{itemObj.XJ}}
          <span
            v-if="(itemObj.XJ!=itemObj.JE && itemObj.JE!=0 && itemObj.JE!=null)"
          >原价 {{itemObj.JE }}</span>
        </div>
        <div class="jg" :style="textColor" v-else>￥{{itemObj.XJ}}</div>
        <div class="jf">
          剩余
          <span :style="textColor">{{itemObj.KC}}</span>
        </div>
      </div>
      <div class="zsjf1" v-if="itemObj.JF">{{itemObj.JF}}积分</div>
      <div class="line20"></div>

      <div class="zsjf" v-if="itemObj.ZSJF">
        赠送
        <span>{{itemObj.ZSJF}}</span>积分
      </div>
      <!-- <div class="spms">
              {{itemObj}}
      </div>-->
      <!-- <div class="spjssm" v-html="itemObj.MS">

      </div>-->

      <mt-navbar v-model="selected">
        <mt-tab-item id="1">商品详情</mt-tab-item>
        <mt-tab-item id="2">兑换须知</mt-tab-item>
      </mt-navbar>
      <div class="xqxz">
        <!-- tab-container -->
        <mt-tab-container v-model="selected">
          <mt-tab-container-item id="1">
            <div class="spdetail contentA" v-html="itemObj.MS"></div>
          </mt-tab-container-item>
          <mt-tab-container-item id="2">
            <!-- {{itemObj.DHGZ}} -->
            <div class="contentA" v-html="itemObj.DHGZ"></div>
          </mt-tab-container-item>
        </mt-tab-container>
      </div>
    </div>
    <div class="footbuy" @click="exchangeFn2()" :style="backgroundColor">立即抢购</div>

   
    <!--底部占位-->
    <div class="zanwei-bottom"></div>
   
  </div>
</template>

<script>
import api from "@/api/api";
import pay from "@/api/pay";
import { MessageBox, Swipe, SwipeItem, Toast } from "mint-ui";

export default {
  data() {
    return {
      itemObj: {},
      cgts: false,
      selected: "1",
      userlist: {
        name: "",
        idcard: "",
        address: ""
      },
      specShow: false,
      buy: "",
      number: 1
    };
  },
  computed: {
    sumAll() {
      if (this.itemObj && this.itemObj.XJ != null) {
        return (this.itemObj.XJ * this.number).toFixed(2);
      }
    }
  },
  methods: {
    exchangeFn2(){
      Toast({
            message: "预览页面不能抢购",
            duration: 2000
          });
    },
    /**
     * @param ID 礼品ID
     */
    getGiftDetailFn(id) {
      let page = this;
      api.scoreToGiftDetail_yl(page, id, cb);

      function cb(res) {
        if (res.code == 0) {
          let data = JSON.parse(res.data);
          console.log(data);
          page.$store.state.title = data.SPMC;
          let TP = data.TP.map(x => {
            return page.host.filehost + x;
          });
          data.TP = TP;
          let XQT = data.XQT.map(x => {
            return page.host.filehost + x;
          });
          data.XQT = XQT;

          page.itemObj = data;

          page.$nextTick(function() {
            uParse(".contentA", {
              rootPath: "/static/libs/ueditor/"
            });
          });
        } else {
          Toast({
            message: res.msg,
            duration: 2000
          });
          setTimeout(function() {
            page.$router.go(-1);
          }, 2000);
        }
      }
    }
  },
  mounted() {
    let id = this.$route.params.id;
    this.pdid = id;
    this.getGiftDetailFn(id);
  }
};
</script>

<style lang="less">
li {
  list-style: none;
}

.insetbox2 {
  // padding: 0 0.2rem;
  // padding-top: 0.15rem;
  background-color: #e9e9e9;
}

.rapdetail {
  background-color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0.4rem 0.3rem;

  .ph_faddish {
    img {
      width: 6.2rem;
      height: 6.2rem;
    }
  }

  .name_faddish {
    margin: 0.38rem 0;
    width: 6.2rem;
    border-top: 0.04rem solid #e2e2e2;
    border-bottom: 0.04rem solid #e2e2e2;
    padding: 0.05rem 0;

    .tit {
      font-size: 0.3rem;
      color: #e20010;
      line-height: 0.5rem;
    }

    ul {
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 0.1rem 0;

      .btn_faddish {
        width: 2.6rem;
        height: 0.88rem;
        border-radius: 0.12rem;
        line-height: 0.88rem;
        text-align: center;
        color: #fff;
        font-size: 0.4rem;
        background-color: #f05dc4;
      }

      .price {
        margin-left: 0.4rem;
        color: #aeaeae;

        div {
          font-size: 0.24rem;
          line-height: 0.4rem;
          text-align: left;
        }

        p {
          font-size: 0.38rem;
          line-height: 0.54rem;
          color: #747273;
        }
      }
    }
  }

  .detail_faddish {
  }
}

// newweigang
.hbbox {
  .topimg {
    height: 4rem;

    img {
      width: 100%;
      height: 100%;
    }
  }

  .title {
    font-weight: bold;
    font-size: 0.36rem;
    padding: 0.2rem 0.2rem 0.1rem 0.2rem;
  }

  .detailsm {
    display: flex;
    justify-content: space-between;
    align-items: center;
    // border-bottom: 8px solid #f4f4f4;
    .jg {
      color: #f05dc4;
      font-size: 0.42rem;
      font-weight: bold;
      padding: 0.2rem 0.2rem 0.2rem 0.2rem;

      span {
        font-size: 0.28rem;
        text-decoration: line-through;
        color: #999999;
        margin-left: 0.5rem;
      }
    }

    .jf {
      padding-right: 0.2rem;
      font-size: 0.28rem;
      color: #666666;

      span {
        color: #f05dc4;
      }
    }
  }

  .zsjf {
    border-bottom: 1px solid #f4f4f4;
    padding: 0.2rem 0.2rem 0.2rem 0.2rem;
    color: #f05dc4;
    font-size: 0.3rem;

    span {
      color: #f05dc4;
      font-size: 0.3rem;
    }
  }

  .zsjf1 {
    border-bottom: 1px solid #f4f4f4;
    padding: 0rem 0.2rem 0.2rem 0.2rem;
    color: #999999;
    font-size: 0.3rem;
  }

  .spjssm {
    border-bottom: 8px solid #f4f4f4;
    padding: 0.1rem 0.2rem 0.3rem 0.2rem;
    color: #666666;
  }

  .xqxz {
    padding: 10px;
  }
}

.footbuy {
  position: fixed;
  bottom: 0;
  width: 100%;
  text-align: center;
  background-color: #f05dc4;
  color: #fff;
  height: 48px;
  line-height: 48px;
  font-size: 18px;
}

// 提示
.zccg {
  width: 100%;
  top: 0;

  .zccgbox {
    // padding-top: 0.7rem;
    position: absolute;
    border-radius: 5px;
    z-index: 10;
    width: 80%;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    margin: auto;
    // height: 7.5rem;
    height: 5rem;
    background-color: #ffffff;
    // color: #ffffff;
    text-align: center;
    color: #333333;

    .close {
      position: absolute;
      right: 8px;
      top: 8px;

      .iconfont {
        font-size: 20px;
        color: #666666;
      }
    }

    .tstitle {
      text-align: center;
      font-size: 16px;
      font-weight: bold;
      padding: 12px;
    }

    .tsms {
      font-size: 14px;
      color: #666666;
      padding: 10px 26px 20px 26px;
    }

    .tscontent {
      ul {
        li {
          border: 1px solid #e6e6e6;
          margin: 10px;
          border-radius: 5px;
          overflow: hidden;
        }
      }
    }

    .zcbtn {
      margin: 0 10px;
    }
  }

  .zccgbg {
    background-color: #000000;
    position: fixed;
    opacity: 0.5;
    width: 100%;
    height: 100vh;
    top: 0;
    z-index: 9;
  }
}

.sd_spec {
  width: 100%;
  padding-top: 0.3rem;

  .title {
    padding: 0 0.3rem;
    font-size: 0.36rem;
    line-height: 0.8rem;
    font-weight: bold;
    position: relative;
    align-items: center;
    display: flex;

    .name {
      max-width: 4.5rem;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .price {
      color: #ee0017;
      margin-left: 0.15rem;
    }

    .close {
      width: 0.6rem;
      height: 0.6rem;
      border-radius: 50%;
      border: 0.01rem solid #dcdcdc;
      text-align: center;
      line-height: 0.6rem;
      position: absolute;
      top: -0.1rem;
      right: 0.3rem;
      color: #dcdcdc;

      i {
        font-size: 0.3rem;
      }
    }
  }

  .hasxz {
    padding: 0 0.3rem;
    height: 0.5rem;
    display: flex;
    align-items: center;

    .selBox {
      margin: 0 0.1rem;
    }
  }

  .types {
    padding: 0 0.3rem;
    padding-bottom: 0.15rem;

    .tit {
      line-height: 0.6rem;
      font-size: 0.28rem;
    }

    .ilist {
      display: flex;
      align-items: center;
      justify-content: space-between;
      flex-wrap: wrap;

      .item {
        width: 1.56rem;
        height: 0.7rem;
        border: 0.01rem solid #e6e6e6;
        border-radius: 0.06rem;
        font-size: 0.26rem;
        margin-bottom: 0.1rem;
        text-align: center;
        line-height: 0.7rem;
      }

      li.selit {
        background-color: #f05dc4;
        color: #ffffff;
      }
    }
  }

  .numb {
    border-top: 0.01rem solid #e6e6e6;
    height: 1rem;
    padding: 0 0.27rem 0 0.42rem;
    display: flex;
    align-items: center;
    justify-content: space-between;

    span {
      font-size: 0.34rem;
    }

    ul {
      display: flex;
      align-items: center;

      li {
        font-size: 0.36rem;
        width: 0.64rem;
        height: 0.64rem;
        line-height: 0.62rem;
        text-align: center;
      }

      .lef,
      .rig {
        font-size: 0.5rem;
        border-radius: 50%;
        background-color: #f0f0f0;
        color: #b3b3b3;
      }

      .mid {
        margin: 0 0.05rem;
        line-height: 0.64rem;
      }

      li.addsub {
        color: #f05dc4;
      }
    }
  }

  .qgbtn {
    width: 100%;
    height: 0.96rem;
    line-height: 0.96rem;
    text-align: center;
    font-size: 0.34rem;
    color: #ffffff;
    background-color: #f05dc4;
  }
}
</style>
